﻿using UnityEngine;
using System.Collections;

namespace UI
{
    public class UIHeroTalentTemplete :MonoBehaviour
    {
        //未激活
        public GameObject talentNameTextInAc;
        public GameObject talentDescribeTextInAc;

        //激活的
        public GameObject talentNameTextAct;
        public GameObject talentDescribeTextAct;

        public GameObject active;//激活
        public GameObject inactive;//未激活

        public UISprite inAcSpr;
        public UISprite acSpr;

        public bool isActive;

        public void Init(UITalent talent,bool isMine)
        {
            var id = talent.data.talentId;
            var strName = "name_" + id;
            var strDes = "desc_" + id;

            Init(TableTextBlo.GetText(strName), TableTextBlo.GetText(strDes), talent.isActived && isMine);
        }
        void Init( string talentName, string describe, bool active )
        {
            //描述文字
            talentDescribeTextInAc.GetComponent<UILabel>().text = describe;
            talentDescribeTextAct.GetComponent<UILabel>().text = describe;

            talentNameTextAct.GetComponent<UILabel>().text = talentName;
            talentNameTextInAc.GetComponent<UILabel>().text = talentName;

            this.name = talentName;

            SetActiveModule( active );
        }

        public int Height
        {
            get
            {
                if( isActive )
                {
                    return talentDescribeTextAct.GetComponent<UILabel>().height+20;
                }
                else
                {
                    return talentDescribeTextInAc.GetComponent<UILabel>().height+20;
                }
            }
        }


        protected void SetActiveModule( bool active )
        {
            this.isActive = active;
            this.active.SetActive( active );
            this.inactive.SetActive( !active );
        }
    }
}